export function transCamel(_str, symbol = '-') {
    const str = _str[0].toLowerCase() + _str.substr(1);
    return str.replace(/([A-Z])/g, $1 => `${symbol}${$1.toLowerCase()}`);
}

export function getLocaleStr(obj, type = 'zh') {
    return typeof obj === 'object' ? obj[type] : obj;
}

/**
 * 出差计算总预算
 * @param value
 * @param transportExpense
 * @param businessAllowance
 * @param otherExpense
 */
export const getTotalExpense = (
    hotelExpense,
    transportExpense,
    businessAllowance,
    otherExpense
) => {
    const nHotelExpense = Number(hotelExpense) || 0;
    const nTransportExpense = Number(transportExpense) || 0;
    const nBusinessAllowance = Number(businessAllowance) || 0;
    const nOtherExpense = Number(otherExpense) || 0;

    if (
        Number.isNaN(nHotelExpense) ||
        Number.isNaN(nTransportExpense) ||
        Number.isNaN(nBusinessAllowance) ||
        Number.isNaN(nOtherExpense)
    ) {
        return 0;
    }
    return (
        nHotelExpense + nTransportExpense + nBusinessAllowance + nOtherExpense
    );
};
